package com.shigu.agent.model.impl;

import com.opentae.data.mall.beans.ManagerUser;
import com.opentae.data.mall.beans.MoTown;
import com.opentae.data.mall.interfaces.ManagerUserMapper;
import com.opentae.data.mall.interfaces.MoTownMapper;
import com.opentae.data.mall.interfaces.MoUserAccountMapper;
import com.shigu.agent.bo.AgentBO;
import com.shigu.agent.bo.RateBO;
import com.shigu.agent.bo.YeepayBO;
import com.shigu.agent.exceptions.AgentException;
import com.shigu.agent.exceptions.YeepayException;
import com.shigu.agent.model.MoAgent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Component
@Scope("prototype")
public class MoAgentImpl extends MoUserImpl implements MoAgent{

    @Autowired
    private ManagerUserMapper managerUserMapper;

    @Autowired
    private MoUserAccountMapper moUserAccountMapper;


    public MoAgentImpl() {
    }

    public MoAgentImpl(AgentBO userinfo) {
        super(userinfo);
    }

    public MoAgentImpl(Long userId) {
        super(userId);
    }


    @Override
    public void joinBusiness(Long userId) {
        ManagerUser business=new ManagerUser();
        business.setUserId(userId);
        business.setAgentId(getUserId());
        managerUserMapper.updateByPrimaryKeySelective(business);
    }

    @Override
    public void addProfit(Double addMoney) {
        moUserAccountMapper.addProfit(getUserId(),addMoney,addMoney<0?-addMoney:0);
    }


}
